<% @title_for_header_only = t('.title', username: @user.display_id) %>

<% content_for :title do %>
  <header class="profile__header">
    <div class="profile__header__name-wrap">
      <div id="avatar-frame">
        <%= avatar(300, 'profile_gravatar', @user, class: 'profile__header__avatar') %>
      </div>

      <% if @user.full_name.present? %>
        <h1 id="profile-full-name" class="profile__header__name t-display-full-name">
          <%= link_to(@user.full_name, profile_path(@user.display_id), class: "t-link--black") %>
        </h1>

        <h1 id="profile-name" class="profile__header__username t-display-username">
          <%= link_to(@user.display_handle, profile_path(@user.display_id), class: "t-link--black") %>
        </h1>
      <% else %>
        <h1 id="profile-name" class="profile__header__name t-display">
          <%=
            link_to(
              @user.display_handle, profile_path(@user.display_id),
              class: "t-link--black"
            )
          %>
        </h1>
      <% end %>

      <% if @user == current_user %>
        <div id="profile-settings">
          <%=
            link_to(
              t("layouts.application.header.settings"),
              edit_settings_path,
              id: "edit-settings",
              class: "profile__header__attribute t-link--black",
              "data-icon": "★"
            )
          %>
        </div>

        <div id="downloads-ego">
          <%=
            link_to(
              "Edit Profile",
              edit_profile_path,
              id: "edit-profile",
              class: "profile__header__attribute t-link--black",
              "data-icon": "☺"
            )
          %>
        </div>
      <% else %>
        <% if @user.public_email? %>
          <p id="profile-email">
            <%=
              mail_to(
                @user.email,
                "Email Me",
                encode: "hex",
                class: "profile__header__attribute t-link--black",
                "data-icon" => "✉"
              )
            %>
          </p>
        <% end %>

        <% if @user.twitter_username.present? %>
          <%=
            image_tag(
              "/images/x_icon.png",
              alt: "X icon",
              class: "profile__header__icon"
            )
          %>

          <%=
            link_to(
              twitter_username(@user),
              twitter_url(@user),
              class: "profile__header__attribute t-link--black"
            )
          %>
        <% end %>
      <% end %>
    </div>

    <div class="profile__downloads-wrap">
      <h4 class="gem__downloads__heading t-text--s">
        <%= t('stats.index.total_gems') %>
      </h4>

      <h2 id="profile-gems-count" class="gem__downloads">
        <%= @user.total_rubygems_count.to_s %>
      </h2>

      <h4 id="downloads" class="gem__downloads__heading t-text--s">
        <%= t('total_downloads') %>
      </h4>

      <h2 id="downloads_count" class="gem__downloads">
        <%= number_with_delimiter(@user.total_downloads_count) %>
      </h2>
    </div>
  </header>
<% end %>

<div id="profile">
  <div class="profile-list">
    <ul>
      <%= render partial: 'rubygem', collection: @rubygems %>
    </ul>
  </div>
</div>
